from skimage import io
from skimage import data
from skimage import filters
from skimage import color
import matplotlib.pyplot as plt


# img = io.imread('../data/lena.jpg')
# print(type(img))
# print(img.shape)
# io.imshow(img)
# io.show()
# camera = data.camera()
# print(type(camera))
# io.imshow()
# io.show()
# coins = data.coins()
# io.imshow(coins)
# io.show()
# threshold_value = filters.threshold_otsu(coins)
# print(threshold_value)
img = io.imread('../data/lena.jpg')
fig, axes = plt.subplots(2, 4, figsize=(9, 7))
fig.suptitle('Image Test')
ax = axes.ravel()
ax[0].set_title('original')
ax[0].imshow(img)
channels = []
titles = ['red', 'green', 'blue']
for i in range(3):
    channel = img.copy()
    for j in range(3):
        if i == j:
            pass
        else:
            channel[:, :, j] = 0
    channels.append(channel)
    ax[i+1].set_title(titles[i])
    ax[i+1].imshow(channel)
ax[4].set_title('gray')
ax[4].imshow(color.rgb2gray(img), cmap='gray')
ax[5].set_title('red+green')
ax[5].imshow(channels[0] + channels[1])
ax[6].set_title('red+blue')
ax[6].imshow(channels[0] + channels[2])
ax[7].set_title('red+green+blue')
ax[7].imshow(channels[0] + channels[1] + channels[2])
plt.show()
